// components/custom-tab-bar/index.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {

  },

  /**
   * 组件的初始数据
   */
  data: {
    selected: null,  // 选项卡选中的索引
    color: '#2c2c2c',
    selectedColor: "#36f", // 选中的字体颜色
    // 配置选项卡
    list:[{
      pagePath: "../home/home",
      iconPath: "../images/home_off.png",
      selectedIconPath: "../images/home_on.png",
      text: "首页"
    },{
      pagePath: "../consult/consult",
      iconPath: "../images/consult_off.png",
      selectedIconPath: "../images/consult_on.png",
      text: "咨询"
    },{
      pagePath: "../list/list",
      iconPath: "../images/list_off.png",
      selectedIconPath: "../images/list_on.png",
      text: "消息"
    },{
      pagePath: "../mine/mine",
      iconPath: "../images/mine_off.png",
      selectedIconPath: "../images/mine_on.png",
      text: "我的"
    }]
  },

  /**
   * 组件的方法列表
   */
  methods: {
    /**
     * 自定义选项卡切换的方法
     * @param {*} e 
     */
    switchTab(e){
      let data = e.currentTarget.dataset
      let url = data.path
      if(data.index === this.data.selected){
        return false
      }
      wx.switchTab({url})
    }
  }
})
